$(function(){
	var cookieUserName = $.cookie("login_name");
	var cookiePwd = $.cookie("pwd");
	if(cookieUserName != undefined && cookieUserName && cookiePwd != undefined && cookiePwd){
		 $("#login_name").val(cookieUserName);
		 $("#login_pwd").val(cookiePwd);
	}

	$("#login_btn").click(function(){
		var login_name = $("#login_name").val();
		var pwd = $("#login_pwd").val();
		if(login_name.length < 5 || login_name.length > 20){
			alert("请正确输入用户名");
		}else{
				$.ajax({
					url:"/login/submit?format=json",
					data:{
						"user_name":login_name,
						"pwd":pwd
					},
					type:'post',
					success:function(data){
					if (data.redirect_to == "/index") {
						$.cookie("login_name",login_name, { expires: 30, path: '/' });
						$.cookie("pwd",pwd, { expires: 30, path: '/' });
						window.location.href='/respage/call/venderapp/index.html';
					}else{
						window.location.reload();
					}
				}
			});
		}
	});
});
